/*
 * MiniPOVEditor
 * by Andy Isaacson 10/5/2008
 * Written on a Sunday morning
 * 
 * For the MiniPOV kit - http://ladyada.net/make/minipov3/index.html
 */

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JComponent;


public class Cell extends JComponent {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3479847583427549840L;
	
	private boolean on;
	private Color myColor;
	MiniPOVEditor parent;
	
	public Cell(MiniPOVEditor parent) {
		this.parent = parent;
		on = false;
		myColor = Color.red;
		this.addMouseListener(new MyMouseListener());
	}
	
	public void paintComponent(Graphics g) {
		Dimension mySize = this.getSize();
		Color curColor = Color.black;
		
		if (on) curColor = myColor;
		
		g.setColor(curColor);
		g.fillRect(0, 0, mySize.width, mySize.height);
	}
	
	public boolean isOn() {
		return on;
	}

	public void setOn(boolean on) {
		this.on = on;
		this.repaint();
		parent.stateChanged();
	}
	
}
